********************************************************************************
* Replication code for Finnegan, Jared J. 202X. "Changing Prices in a Changing Climate: Electoral Competition and Fossil Fuel Taxation". Comparative Political Studies. *
********************************************************************************
********************************************************************************
********************************************************************************



*** Load dataset "Finnegan_Changing prices in a changing climate.dta"

*** Generate measure of electoral competition
// For plurality party
gen elect_comp_pl2=(((1-(abs(loss_prob_pl-.5)))/0.5)-1)

// For Prime Minister's party
gen elect_comp_pm2=(((1-(abs(loss_prob_pm-.5)))/0.5)-1)

*** xtset
xtset country_num year



********************************************************************************
******************************** Main results **********************************
********************************************************************************


*********************************** Tables *************************************

*** Table 1: Nominal changes in gasoline tax rates (national currencies) (1988-2013)
tab taxchange_natcurr if tin(1988,2013)

*** Table 2: Electoral competition and gasoline taxation
//Model 1
xtreg gas_excisetax_nomUSDPPP l.elect_comp_pl i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 2
xtreg gas_excisetax_nomUSDPPP l.elect_comp_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)

*** Table 3: Electoral competition and personal costs
//Model 1
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##c.l2.gas_percap_litres_100 i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 2
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##c.l2.gas_percap_litres_100 l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)

*** Table 4: Likely winners, likely losers, and government preferences
//Model 1
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 2
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.left_incum l.green_cab l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 3
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.green_in_gov l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)


************************************ Figures ***********************************

*** Figure 1: Trends in gasoline taxation
xtline gas_excisetax_nomUSDPPP if tin(1988,2013), ytitle("Gasoline tax rate (nominal US cents per liter)") xtitle("Year") xlabel(1990 2000 2010)

*** Figure 2: Trends in electoral competition
xtline elect_comp_pl if tin(1988,2013), ytitle("Electoral competition") xtitle("Year") xlabel(1990 2000 2010) 

*** Figure 3: Marginal effects of electoral competition at different levels of gasoline consumption
quietly: xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##c.l2.gas_percap_litres_100 l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
margins, dydx(l.elect_comp_pl) at(l2.gas_percap_litres_100=(0(2)20)) vsquish
marginsplot, yline(0) xtitle(Gasoline consumption (t-2)) title("") ytitle(Marginal effect on gasoline tax rate)  ///
	xlabel(0 5 10 15 20) ///
	addplot(hist l2gas_percap_litres_100 if tin(1988,2013), percent yaxis(2) yscale(alt lcolor() axis(2)) ylabel(0 "0%" 25 "25%" 50 "50%", labcolor() axis(2) tlcolor(black) tlwidth(thin) labsize(small))  ///
	ytitle("", axis(2))) legend(off)

*** Figure 4: Likely winners versus likely losers
quietly: xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
margins, at(l.loss_prob_pl=(0(.1).8)) 
marginsplot, xtitle(Loss probability (t-1)) ytitle("Gasoline tax rate") title("") ///
	addplot(hist lloss_prob_pl if tin(1988,2013), percent yaxis(2) yscale(alt lcolor() axis(2)) ylabel(0 "0%" 25 "25%" 50 "50%", labcolor() axis(2) tlcolor(black) tlwidth(thin) labsize(small)) ///
	ytitle("", axis(2))) legend(off)

*** Figure 5: Likely winners versus likely losers along left–right dimension
quietly: xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.left_incum l.green_cab l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
margins l.left_incum, at(l.loss_prob_pl=(0(.1).8) l.loss_prob_pl=(0 (.1) .8))
marginsplot, xtitle("Loss probability (t-1)") ytitle("Gasoline tax rate") title("")  ///
	addplot (hist lloss_prob_pl if tin(1988,2013) & lleft_incum==1, percent yaxis(2) yscale(alt lcolor() axis(2)) ylabel(0 "0%" 50 "50%" 100 "100%", labcolor() axis(2) tlcolor(black) tlwidth(thin) labsize(small)) ///
	ytitle("", axis(2))) legend(off)

*** Figure 6: Likely winners versus likely losers along green–non-green dimension
quietly: xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.green_in_gov l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
margins l.green_in_gov, at(l.loss_prob_pl=(0(.1).8) l.loss_prob_pl=(0 (.1).8))
marginsplot, xtitle("Loss probability (t-1)") ytitle("Gasoline tax rate") title("") ylabel(30 35 45 55 65) ///
	addplot (hist lloss_prob_pl if tin(1988,2013) & lgreen_in_gov==1, percent yaxis(2) yscale(alt lcolor() axis(2)) ylabel(0 "0%" 50 "50%" 100 "100%", labcolor() axis(2) tlcolor(black) tlwidth(thin) labsize(small)) ///
	ytitle("", axis(2))) legend(off)

	
	

********************************************************************************
****************************** Online Appendix *********************************
********************************************************************************


********************************** Tables **************************************

*** Table A3. Summary statistics and data sources
summ gas_excisetax_nomUSDPPP perchange loss_prob_pl elect_comp_pl gas_percap_litres_100 gas_expend_GDPnom green_cab left_cab_nogreen per501_avg elect_year deficit debt_hist inflation oil_prod nomgdpgr vat_transfuels gdp_percap_nominal GOV_Cab_GG GOV_Cab_LR single_party polconiii socexp_t_pmp urban_pop incometax eu kp if tin(1988,2013)

*** Table A4. Validating new measure of electoral competition
//Model 1
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##l.i.loss_prob_dummy i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 2
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##l.i.loss_prob_dummy l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)

*** Table A5. Robustness tests (1)
//Model 1
xtreg gas_excisetax_nomUSDPPP l.elect_comp_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(jack)
//Model 2
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##c.l2.gas_percap_litres_100 l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(jack)
//Model 3
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(jack)
//Model 4
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.left_incum l.green_cab l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(jack)
//Model 5
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.green_in_gov l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(jack)
//Model 6
xtreg gas_excisetax_nomUSDPPP l2.elect_comp_pl l2.green_cab l2.left_cab_nogreen l2.per501_avg elect_year l2.oil_prod l2.inflation l2.deficit l2.debt_hist l2.nomgdpgr l2.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 7
xtreg gas_excisetax_nomUSDPPP c.l2.elect_comp_pl##c.l2.gas_percap_litres_100 l2.green_cab l2.left_cab_nogreen l2.per501_avg elect_year l2.oil_prod l2.inflation l2.deficit l2.debt_hist l2.nomgdpgr l2.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 8
xtreg gas_excisetax_nomUSDPPP c.l2.loss_prob_pl##c.l2.loss_prob_pl l2.green_cab l2.left_cab_nogreen l2.per501_avg elect_year l2.oil_prod l2.inflation l2.deficit l2.debt_hist l2.nomgdpgr l2.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 9
xtreg gas_excisetax_nomUSDPPP c.l2.loss_prob_pl##c.l2.loss_prob_pl##i.l2.left_incum l2.green_cab l2.per501_avg elect_year l2.oil_prod l2.inflation l2.deficit l2.debt_hist l2.nomgdpgr l2.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 10
xtreg gas_excisetax_nomUSDPPP c.l2.loss_prob_pl##c.l2.loss_prob_pl##i.l2.green_in_gov l2.left_cab_nogreen l2.per501_avg elect_year l2.oil_prod l2.inflation l2.deficit l2.debt_hist l2.nomgdpgr l2.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)

*** Table A6. Robustness tests (2)
//Model 1
xtreg gas_excisetax_nomUSDPPP l.elect_comp_pm l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 2
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pm##c.l2.gas_percap_litres_100 l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 3
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pm##c.l.loss_prob_pm l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 4
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pm##c.l.loss_prob_pm##i.l.left_incum l.green_cab l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 5
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pm##c.l.loss_prob_pm##i.l.green_in_gov l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 6
xtreg gas_excisetax_nomUSDPPP l.elect_comp_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gdp_percap_nominal l.GOV_Cab_GG l.GOV_Cab_LR l.single_party l.polconiii l.socexp_t_pmp l.urban_pop incometax l.eu l.kp i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 7
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##c.l2.gas_percap_litres_100 l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gdp_percap_nominal l.GOV_Cab_GG l.GOV_Cab_LR l.single_party l.polconiii l.socexp_t_pmp l.urban_pop incometax l.eu l.kp i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 8
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gdp_percap_nominal l.GOV_Cab_GG l.GOV_Cab_LR l.single_party l.polconiii l.socexp_t_pmp l.urban_pop incometax l.eu l.kp i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 9
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.left_incum l.green_cab l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gdp_percap_nominal l.GOV_Cab_GG l.GOV_Cab_LR l.single_party l.polconiii l.socexp_t_pmp l.urban_pop incometax l.eu l.kp i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 10
xtreg gas_excisetax_nomUSDPPP c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.green_in_gov l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gdp_percap_nominal l.GOV_Cab_GG l.GOV_Cab_LR l.single_party l.polconiii l.socexp_t_pmp l.urban_pop incometax l.eu l.kp i.year if tin(1988,2013), fe vce(cluster country_num)

*** Table A7. Robustness tests (3)
//Model 1
xtlogit taxinc_natcurr l.elect_comp_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gas_excisetax_nomUSDPPP i.year if tin(1988,2013), fe or
//Model 2
xtlogit taxinc_natcurr c.l.elect_comp_pl##c.l2.gas_percap_litres_100 l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gas_excisetax_nomUSDPPP  i.year if tin(1988,2013), fe or
//Model 3
xtreg perchange l.elect_comp_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gas_excisetax_nomUSDPPP i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 4
xtreg perchange c.l.elect_comp_pl##c.l2.gas_percap_litres_100 l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gas_excisetax_nomUSDPPP i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 5
xtreg perchange c.l.loss_prob_pl##c.l.loss_prob_pl l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gas_excisetax_nomUSDPPP i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 6
xtreg perchange c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.left_incum l.green_cab l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gas_excisetax_nomUSDPPP i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 7
xtreg perchange c.l.loss_prob_pl##c.l.loss_prob_pl##i.l.green_in_gov l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels l.gas_excisetax_nomUSDPPP i.year if tin(1988,2013), fe vce(cluster country_num)

*** Table A8. Electoral competition and gasoline expenditure
//Model 1
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##c.l2.gas_expend_GDPnom l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
//Model 2
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##c.l2.gas_expend_GDPnom l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(jack)
//Model 3
xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##c.l2.gas_expend_GDPnom l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013) & country_num!=21, fe vce(cluster country_num)


*********************************** Figures ************************************

*** Figure A1. Likely winners vs. likely losers
quietly: xtreg gas_excisetax_nomUSDPPP c.l.elect_comp_pl##l.i.loss_prob_dummy l.green_cab l.left_cab_nogreen l.per501_avg elect_year l.oil_prod l.inflation l.deficit l.debt_hist l.nomgdpgr l.vat_transfuels i.year if tin(1988,2013), fe vce(cluster country_num)
margins, at(l.elect_comp_pl=(0 (0.2) 1) l.loss_prob_dummy=(0, 1)) vsquish
marginsplot, legend(order(4 "Likely winner" 3 "Likely loser")) xtitle(Electoral competition) ytitle(Predicted Gasoline Tax Rate (USD cents/liter))

*** Figure A2. Binning estimates for gasoline consumption
interflex gas_excisetax_nomUSDPPP lelect_comp_pl l2gas_percap_litres_100 lgreen_cab lleft_cab_nogreen lper501_avg elect_year loil_prod linflation ldeficit ldebt_hist lnomgdpgr lvat_transfuels if tin(1988,2013), fe(country_num year) cl(country_num) xdistr(density) ylabel(gas tax) dlabel(electoral competition) xlabel(Gasoline consumption (100s liters per capita)) 

*** Figure A3. Kernel estimates for gasoline consumption
interflex gas_excisetax_nomUSDPPP lelect_comp_pl l2gas_percap_litres_100 lgreen_cab lleft_cab_nogreen lper501_avg elect_year loil_prod linflation ldeficit ldebt_hist lnomgdpgr lvat_transfuels if tin(1988,2013), fe(country_num year) cl(country_num) type(kernel) ylabel(gas tax) dlabel(electoral competition) xlabel(Gasoline consumption (100s liters per capita)) xdistr(density) bw(6.0)

*** Figure A4. Binning estimates for gasoline consumption
interflex gas_excisetax_nomUSDPPP lelect_comp_pl l2gas_percap_litres_100 lgreen_cab lleft_cab_nogreen lper501_avg elect_year loil_prod linflation ldeficit ldebt_hist lnomgdpgr lvat_transfuels if tin(1988,2013), fe(country_num year) cl(country_num) xdistr(density) ylabel(gas tax) dlabel(electoral competition) xlabel(Gasoline consumption (100s liters per capita)) cut(6.83 12.32 17.81)

*** Figure A5. Marginal effect of electoral competition at different levels of gasoline expenditure with binning estimates
interflex gas_excisetax_nomUSDPPP lelect_comp_pl l2gas_expend_GDPnom lgreen_cab lleft_cab_nogreen lper501_avg elect_year loil_prod linflation ldeficit ldebt_hist lnomgdpgr lvat_transfuels if tin(1988,2013), fe(country_num year) cl(country_num) xdistr(density) ylabel(gas tax) dlabel(electoral competition) xlabel(Gasoline expenditure (% of income))

*** Figure A6. Kernel estimates for gasoline expenditure
interflex gas_excisetax_nomUSDPPP lelect_comp_pl l2gas_expend_GDPnom lgreen_cab lleft_cab_nogreen lper501_avg elect_year loil_prod linflation ldeficit ldebt_hist lnomgdpgr lvat_transfuels if tin(1988,2013), fe(country_num year) cl(country_num) type(kernel) xdistr(density) bw(1.65) ylabel(gas tax) dlabel(electoral competition) xlabel(Gasoline expenditure (% of income))

